Audio devices such as earphones or external speakers have plugs for plugging into electronic devices. The plug for an external speaker includes a left audio contact pin, a right audio contact pin, and a ground contact pin, while the plug for an earphone with a microphone function includes a left audio contact pin, a right audio contact pin, a ground contact pin, and a microphone contact pin. For an electronic device such as a mobile phone, it can always correctly detect, upon insertion, the plug of the earphone with microphone function; however it cannot always correctly detect the plug of the external speaker. The failure of the electronic device to detect the insertion of the plug of the external speaker can cause confusion to the user thereof.